package com.wish.g1.finance.controller;


import com.wish.g1.finance.entity.RentInstallment;
import com.wish.g1.finance.entity.SfLoan;
import com.wish.g1.finance.entity.vo.RentInstallmentVo;
import com.wish.g1.finance.service.IFactoringService;
import com.wish.g1.finance.service.IRentInstallmentService;
import com.wish.g1.finance.service.ISfLoanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 收房贷申请信息 前端控制器
 * </p>
 *
 * @author wxh
 * @since 2022-11-18
 */
@RestController
@RequestMapping("/loan")
public class SfLoanController {
    @Autowired
    private IRentInstallmentService rentInstallmentService;
    @Autowired
    private IFactoringService factoringService;
    @Autowired
    private ISfLoanService sfLoanService;

    /**
     * 修改收房贷申请信息
     * @return
     */
    @PutMapping("updateById")
    public boolean edit(@RequestBody RentInstallmentVo shenhe)
    {
        if (shenhe.getJrProductType().equals(1)){
            System.err.println(shenhe);
            RentInstallment rentInstallment = rentInstallmentService.selectRentInstallment(Long.valueOf(shenhe.getId()));
            System.out.println("++++"+shenhe);
            rentInstallment.setApplyState(shenhe.getApplyState());
            return rentInstallmentService.updateById(rentInstallment);
        }else if (shenhe.getJrProductType().equals(2)){
            SfLoan sfLoanServiceById = sfLoanService.getById(shenhe.getId());
            sfLoanServiceById.setApplyState(shenhe.getApplyState());
            return sfLoanService.updateById(sfLoanServiceById);
        }

        return false;
    }

}
